using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using StateMachine_Graphical_Editor.Utils;

namespace StateMachine_Graphical_Editor.Forms
{
    /// <summary>
    /// Dialog to select transitions to delete if a connector 
    /// represents multiple logical transition
    /// </summary>
    public partial class DeleteTransitionsSelector : Form
    {
        #region Members:

        MultipleNames transitionsNames;

        #endregion

        #region C'tors:

        public DeleteTransitionsSelector()
        {
            InitializeComponent();
            transitionsNames = new MultipleNames();
        }

        //get a list of names to display:
        public DeleteTransitionsSelector(MultipleNames names)
            : this()
        {
            transitionsNames = names; //ref to same list
            foreach (string name in names.NamesList)
            {
                this.transitionsToDeleteCheckBox.Items.Add(name);
            }

        }

        #endregion

        #region Event handlers:

        private void cancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            //what was checked has to be deleted
            for(int i = 0; i < transitionsToDeleteCheckBox.CheckedItems.Count; i++)
            {
                string item = transitionsToDeleteCheckBox.CheckedItems[i] as string; 
                transitionsNames.removeName(item);
                //TODO - remove logic transition from TransitionCollection
            }
            Close();
        }

        private void selectAllButton_Click(object sender, EventArgs e)
        {
            for (int idx = 0; idx < transitionsToDeleteCheckBox.Items.Count; idx++)
            {
                transitionsToDeleteCheckBox.SetItemChecked(idx, true);
            }
        }

        private void selectNoneButton_Click(object sender, EventArgs e)
        {
            for (int idx = 0; idx < transitionsToDeleteCheckBox.Items.Count; idx++)
            {
                transitionsToDeleteCheckBox.SetItemChecked(idx, false);
            }
        }

        #endregion
    }
}